package top.lshaci.learning.springboot.web.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.lshaci.learning.springboot.web.servlet.HelloServlet;

import javax.servlet.annotation.WebListener;
import javax.servlet.annotation.WebServlet;
import javax.servlet.annotation.WebFilter;

/**
 * ServletRegistrationConfig
 *
 * <p>使用原生的servlet组件</p>
 *
 * <pre>
 * 一、使用registration bean的方式
 *     1、注册servlet：{@link ServletRegistrationBean}
 *     2、注册filter：{@link FilterRegistrationBean}
 *     3、注册listener：{@link ServletListenerRegistrationBean}
 *
 * 二、使用注解的方式
 *     0、开启servlet组件扫描：{@link ServletComponentScan}
 *     1、注册servlet：{@link WebServlet}
 *     2、注册filter：{@link WebFilter}
 *     3、注册listener：{@link WebListener}
 * </pre>
 * @author lshaci
 * @since 1.0.0
 */
@Configuration
public class ServletRegistrationConfig {

    @Bean
    public ServletRegistrationBean<HelloServlet> helloServlet() {
        return new ServletRegistrationBean(new HelloServlet(), "/hello");
    }
}
